{% extends "base.html" %}

{% block title %}修改密码 - SteHub{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8 col-lg-6">
        <div class="card">
            <div class="card-header">
                <h4 class="mb-0"><i class="fas fa-key me-2"></i>修改密码</h4>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ url_for('auth.change_password') }}">
                    <div class="mb-3">
                        <label for="current_password" class="form-label">当前密码</label>
                        <input type="password" class="form-control" id="current_password" 
                               name="current_password" required placeholder="请输入当前密码">
                    </div>
                    
                    <div class="mb-3">
                        <label for="new_password" class="form-label">新密码</label>
                        <input type="password" class="form-control" id="new_password" 
                               name="new_password" required placeholder="至少8位字符" minlength="8">
                        <div class="form-text">密码应包含字母、数字和特殊字符</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="confirm_password" class="form-label">确认新密码</label>
                        <input type="password" class="form-control" id="confirm_password" 
                               name="confirm_password" required placeholder="再次输入新密码">
                    </div>
                    
                    <div class="d-grid gap-2">
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save me-2"></i>更新密码
                        </button>
                        <a href="{{ url_for('auth.profile') }}" class="btn btn-outline-secondary">
                            返回个人资料
                        </a>
                    </div>
                </form>
            </div>
        </div>

        <!-- 密码安全提示 -->
        <div class="card mt-4">
            <div class="card-header">
                <h6 class="mb-0"><i class="fas fa-shield-alt me-2"></i>密码安全提示</h6>
            </div>
            <div class="card-body">
                <ul class="list-unstyled mb-0">
                    <li><i class="fas fa-check text-success me-2"></i>使用至少8位字符的密码</li>
                    <li><i class="fas fa-check text-success me-2"></i>混合使用大小写字母、数字和符号</li>
                    <li><i class="fas fa-check text-success me-2"></i>避免使用个人信息作为密码</li>
                    <li><i class="fas fa-check text-success me-2"></i>定期更换密码</li>
                    <li><i class="fas fa-check text-success me-2"></i>不要在多个平台使用相同密码</li>
                </ul>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
document.addEventListener('DOMContentLoaded', function() {
    const newPassword = document.getElementById('new_password');
    const confirmPassword = document.getElementById('confirm_password');
    
    function validatePassword() {
        if (newPassword.value !== confirmPassword.value) {
            confirmPassword.setCustomValidity('新密码不一致');
        } else {
            confirmPassword.setCustomValidity('');
        }
    }
    
    newPassword.addEventListener('change', validatePassword);
    confirmPassword.addEventListener('keyup', validatePassword);
});
</script>
{% endblock %}